Skip to content

feat(crispasr): add word-level timestamp support - #10403

Merged
mudler merged 2 commits into
mudler:masterfrom
fqscfqj:feat/crispasr-word-timestamps
Jun 19, 2026
Merged

feat(crispasr): add word-level timestamp support#10403
mudler merged 2 commits into
mudler:masterfrom
fqscfqj:feat/crispasr-word-timestamps

Conversation

@fqscfqj

@fqscfqj fqscfqj commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Add word-level timestamp extraction to the crispasr backend. The CrispASR C library (libgocraspasr) already exports word accessor functions, but the Go wrapper did not bind or call them.

What Changed

C shim (backend/go/crispasr/cpp/crispasr_shim.{h,cpp})

Added wrapper functions for two families of CrispASR word accessors:

Function family Scope Use case
get_word_count/text/t0/t1(seg_i, ...) Per-segment Whisper-like backends
get_parakeet_word_count/text/t0/t1(...) Global (no segment index) Parakeet TDT/CTC/RNNT models

Go wrapper (backend/go/crispasr/{main.go,gocrispasr.go})

  • Registered the new C functions via purego.RegisterLibFunc.
  • In AudioTranscription, after transcription, populates TranscriptSegment.Words:
    • Tries session-based per-segment word functions first.
    • Falls back to parakeet-specific global word list when session word count is 0 (and only on segment 0 to avoid duplication).

Why two function families?

CrispASR uses different backends internally. Whisper-style backends expose word timestamps per-segment through the session result (crispasr_session_result_n_words(result, seg_i)). Parakeet TDT models expose word timestamps globally through crispasr_parakeet_result_n_words(result) — the session-level word functions return 0 for these models.

Depends on

#10402 — the gRPC server wrapper must forward the Words field for the timestamps to reach the HTTP response.

Testing

Verified end-to-end on LocalAI v4.4.3 (Docker, RTX 3090) with parakeet-tdt-0.6b-v3 via the crispasr backend:

{
  "segments": [{
    "id": 0,
    "start": 0.16,
    "end": 10.48,
    "text": "Been playing lots of Nordic Souls recently. Enjoy the list, but looking for something graphically better? Things I want to prioritize.",
    "words": [
      {"start": 0.16, "end": 0.4, "text": "Been"},
      {"start": 0.4, "end": 0.72, "text": "playing"},
      {"start": 0.72, "end": 0.88, "text": "lots"},
      {"start": 0.88, "end": 1.04, "text": "of"},
      {"start": 1.04, "end": 1.6, "text": "Nordic"},
      {"start": 1.6, "end": 2.0, "text": "Souls"},
      ...
    ]
  }]
}

21 words returned with accurate timestamps matching the TDT duration head output.

Add word-level timestamp extraction to the crispasr backend by calling
the CrispASR C library's word accessor functions that are already
exported by libgocraspasr but were not previously bound by the Go
wrapper.

Two families of word functions are supported:

1. Session-based (get_word_count/text/t0/t1) — works per-segment for
   whisper-like backends.
2. Parakeet-specific (get_parakeet_word_count/text/t0/t1) — returns a
   global word list for TDT/CTC/RNNT parakeet models where the session
   API does not expose per-segment word data.

The Go code tries session-based first and falls back to parakeet-specific
when the session word count is zero.

Depends on mudler#10402 (grpc server Words forwarding) for the words to reach
the HTTP response.

Signed-off-by: fqscfqj <fqscfqj@outlook.com>
@fqscfqj
fqscfqj force-pushed the feat/crispasr-word-timestamps branch from 31f2d8b to b2c8332 Compare June 19, 2026 10:44
BSD sed requires -i '' for in-place editing while GNU sed uses -i.
Replace with -i.bak which works on both platforms, then remove the
backup file.

Signed-off-by: fqscfqj <fqscfqj@outlook.com>
@fqscfqj

fqscfqj commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi! The darwin (macOS Metal) build failure was caused by a pre-existing incompatibility in the Makefile — sed -i requires a different syntax on BSD sed (macOS) vs GNU sed (Linux).

Fix applied: Replaced sed -i with sed -i.bak ... && rm -f *.bak, which is portable across both GNU and BSD sed. This bug was introduced on master (commit 9a88eb8) before this PR.

The remaining CI jobs (linux/amd64, linux/arm64, CUDA 12/13, ROCm, Vulkan, SYCL) all passed successfully. Could you please approve the workflow run so we can verify the darwin build passes now? Thanks!

@mudler
mudler merged commit 72d46c1 into mudler:master Jun 19, 2026
67 checks passed
@localai-bot localai-bot added the enhancement New feature or request label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants